package net.zjitc.controller;

import net.zjitc.aop.Pager;
import net.zjitc.pojo.api.Result;
import net.zjitc.pojo.dto.query.extend.CategoryQueryDto;
import net.zjitc.pojo.entity.Category;
import net.zjitc.service.CategoryService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

//书籍类别
@RestController
@RequestMapping(value = "/category")
public class CategoryController {

    @Resource
    private CategoryService categoryService;
    //书籍类别增加
    @PostMapping(value = "/save")
    public Result<Void> save(@RequestBody Category category) {
        return categoryService.save(category);
    }
    //删除
    @PostMapping(value = "/batchDelete")
    public Result<Void> batchDelete(@RequestBody List<Integer> ids) {
        return categoryService.batchDelete(ids);
    }
    //修改
    @PutMapping(value = "/update")
    public Result<Void> update(@RequestBody Category category) {
        return categoryService.update(category);
    }
    //查询
    @Pager
    @PostMapping(value = "/query")
    public Result<List<Category>> query(@RequestBody CategoryQueryDto categoryQueryDto) {
        return categoryService.query(categoryQueryDto);
    }

}
